<!DOCTYPE html>
<head>
    <title>用户登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content=""/>
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <!-- bootstrap-css -->
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <!-- //bootstrap-css -->
    <!-- Custom CSS -->
    <link href="/css/style.css" rel='stylesheet' type='text/css'/>
    <link href="/css/style-responsive.css" rel="stylesheet"/>
    <!-- font-awesome icons -->
    <link rel="stylesheet" href="/css/font.css" type="text/css"/>
    <link href="/css/font-awesome.css" rel="stylesheet">
    <!-- //font-awesome icons -->
    <script src="/js/jquery2.0.3.min.js"></script>
</head>
<body>
<div class="log-w3">
    <div class="w3layouts-main">
        <h2>信康保险登录</h2>
        <form action="/emp/login" method="post" onsubmit="return getResult();" id="loginForm">
            <input type="text" class="ggg" name="empName" placeholder="请输入用户姓名" id="empName">
            <input type="password" class="ggg" name="empPassword" placeholder="请输入用户密码" id="empPassword" >
            <!--<span><input type="checkbox" />记住密码</span>-->
            <h6><a href="/registration.html">忘记密码?</a></h6>
            <div class="clearfix"></div>
            <input type="submit" value="登录"id="sub">
        </form>
        <!--<p>没有账号?<a href="registration.html">注册账户</a></p>-->
    </div>
</div>

<script src="/js/jquery/jquery.min.js"></script>
<script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="/js/scripts.js"></script>
<script src="/js/jquery.slimscroll.js"></script>
<script src="/js/jquery.nicescroll.js"></script>
<script src="/js/jquery.scrollTo.js"></script>

</body>
</html>
<script>
    $("#sub").click(function () {
       if(!check().form()){
           return;
       }
    });

    var result;//返回账户状态  (冻结false ,正常 true)

    var check =function () {
        return $("#loginForm").validate({
            rules: {
                empName: {
                    required:true
                },
                empPassword:{
                   required:true
                }

            },
            messages: {
                empName: {
                    required: ""
                },
                empPassword:{
                    required:""

                }
            }
        });
    };


    function getResult() {
        if($("#empName").val()!=null){
            $("#empName").blur(function () {
                    $.ajax({
                        type: "POST",
                        url: "/emp/getInfo",
                        data: {
                            empName: $("#empName").val()
                        },
                        dataType: "json",
                        success: function (data) {
                            if(data!=null){
                                if (data.emp.accountState == 1) {
                                    result = false;
                                } else {
                                    result = true;
                                }

                            }
                        }
                    });
            });
        }
        return result;
    };

</script>

